import type { VxeGridProps } from 'vxe-table'

// 查询条件组件 options
interface Options {
  label: string,
  value: string | number,
  props?: any
}

// 查询条件
interface query {
  name: string,
  label: string,
  placeholder?: string,
  props?: any
  type: 'ElCascader' | 'ElCheckbox' | 'ElDatePicker' | 'ElInput' | 'ElInputNumber' | 'ElRadio' | 'ElSelect' | 'ElSwitch',
  options?: Array<Options>,
}

// 默认按钮权限
interface BtnAuth {
  add?: string,
  edit?: string,
  detail?: string,
  delete?: string,
}

// 扩展按钮
interface operatorExBtn {
  name: string,
  label: string,
  auth?: string,
  icon?: string
}

// 表格属性
interface VxeTableProps extends VxeGridProps {
  // 默认按钮
  defaultBtn?: Array<'add' | 'edit' | 'detail' | 'delete'> | BtnAuth,
  url?: string,
  // 自动加载
  autoLoad?: boolean,
  // 展示操作列 默认true
  operatorColumn?: boolean,
  operatorExBtn?: Array<operatorExBtn>
}

// 分页
interface Pagination {
  layout?: string,
  pageSizes?: Array<number>,
  size?: string,
  show?: boolean,
}

// 查询配置
interface QueryConfig {
  type?: 'default' | 'drawer'
}

// 组件属性
interface IProps {
  queryFilter?: Array<query>,
  queryConfig?: QueryConfig,
  table?: VxeTableProps,
  pagination?: Pagination,
  exParams?: any
}

// 默认属性
const defaultProps: IProps = {
  queryFilter: [],
  queryConfig: {
    type: 'drawer',
  },
  exParams: {},
  pagination: {
    layout: 'total, sizes, prev, pager, next, jumper',
    pageSizes: [10, 20, 50, 100, 500],
    size: 'small',
    show: true,
  },
  table: {
    defaultBtn: ['add', 'edit', 'detail', 'delete'],
    operatorColumn: true,
    height: '100%',
    border: 'outer',
    size: 'medium',
    showOverflow: true,
    columnConfig: {
      resizable: true,
    },
    rowConfig: {
      keyField: 'guid',
      isHover: true,
      isCurrent: true,
    },
    stripe: true,
    toolbarConfig: {
      custom: true,
      zoom: true,
      print: true,
      export: true,
      slots: {
        buttons: 'toolbarButtons',
      }
    },
    exportConfig: {},
    printConfig: {},
    customConfig: {
      enabled: true,
      storage: {
        visible: true,
        resizable: true,
        sort: true,
        fixed: true
      }
    }
  }
}

export {
  defaultProps,
}

export type {
  IProps,
  query,
  operatorExBtn,
  VxeTableProps
}